//
//  VISTAMagaTableViewCell.m
//  看杂志
//
//  Created by zcj on 15-12-14.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "VISTAMagaTableViewCell.h"
#import "Grouble.h"
#import "VISTAMagaTableViewModel.h"

@implementation VISTAMagaTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configCell];
    }
    return self;
}

- (void)configCell
{
    CGFloat width = self.frame.size.width;
    self.bg_imageView             = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"微话题列表底_1"]];
    self.bg_imageView.frame       = CGRectMake(5, 5, width-10, 80);
    self.sj_imageView             = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"三角"]];
    self.sj_imageView.frame       = CGRectMake(width-20, 90/2-6, 8, 8);
    self.iconBg_imageView         = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"列表缺省图"]];
    self.iconBg_imageView.frame   = CGRectMake(16, 11, 59, 76);
    self.iconSj_imageView         = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"缺省图阴影"]];
    self.iconSj_imageView.frame   = CGRectMake(16, 9, 59, 72);
    self.icon_imageView           = [[UIImageView alloc]initWithFrame:CGRectMake(22, 15, 47, 60)];
    
    
    
    self.title_label              = [[UILabel alloc]initWithFrame:CGRectMake(87, 11, width-100 - 20, 13)];
    self.title_label.textColor    = [UIColor colorWithRed:0.78 green:0 blue:0 alpha:1];
    self.title_label.font         = [UIFont systemFontOfSize:13];
    self.desc_label               = [[UILabel alloc]initWithFrame:CGRectMake(87, 25, width-100 - 20, 40)];
    self.desc_label.textColor     = [UIColor grayColor];
    self.desc_label.numberOfLines = 0;
    self.desc_label.lineBreakMode = NSLineBreakByCharWrapping;
    self.desc_label.font          = [UIFont systemFontOfSize:10];
    self.pub_time_label           = [[UILabel alloc]initWithFrame:CGRectMake(width-100, 67, 100, 13)];
    self.vol_Label                = [[UILabel alloc]initWithFrame:CGRectMake(87, 67, 120, 13)];
    self.vol_Label.textColor      = [UIColor grayColor];
    self.vol_Label.font           = [UIFont systemFontOfSize:10];
    self.pub_time_label.textColor = [UIColor grayColor];
    self.pub_time_label.font      = [UIFont systemFontOfSize:11];
    
    self.backgroundColor          = [UIColor clearColor];
    
    [self.contentView addSubview:self.bg_imageView];
    [self.contentView addSubview:self.iconBg_imageView];
    [self.contentView addSubview:self.icon_imageView];
    [self.contentView addSubview:self.iconSj_imageView];
    [self.contentView addSubview:self.title_label];
    [self.contentView addSubview:self.desc_label];
    [self.contentView addSubview:self.vol_Label];
    [self.contentView addSubview:self.pub_time_label];
    [self.contentView addSubview:self.sj_imageView];
}
- (void)fillCellWithModel:(VISTAMagaTableViewModel *)model
{
    
    //self.icon_imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.cover]]]];
    
    
    self.vol_Label.text = [NSString stringWithFormat:@"%@年第%@期",model.year,model.vol_year];
    self.title_label.text = [NSString stringWithFormat:@"%@",model.title];
    self.desc_label.text = [NSString stringWithFormat:@"%@",model.desc];
    self.pub_time_label.text = [NSString stringWithFormat:@"%@",model.pub_time];
    [self.icon_imageView setImageWithURL:[NSURL URLWithString:model.cover]  placeholderImage:[UIImage imageNamed:@"dd"]];
}
//
- (void)fillImageViewWith:(UIImage *)image
{
    self.icon_imageView.image = image;
}
+ (VISTAMagaTableViewCell *)cellWithTableView:(UITableView *)tableView
{
    static NSString *reuseID = @"mageCellID";
    VISTAMagaTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];
    if (!cell) {
        cell = [[VISTAMagaTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseID];
    }
    return cell;
}
@end
